<html>
<head><meta charset="utf-8"><title>ICE · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html">ICE</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="247650192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247650192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247650192">(Jul 29 2021 at 22:38)</a>:</h4>
<p>I found an ICE trying some const eval checked for shuffles: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=8a413d31ee0a1504b79d371ec1865b92">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=8a413d31ee0a1504b79d371ec1865b92</a></p>
<p><span class="user-mention" data-user-id="326176">@Boxy [she/her]</span> do you happen to know if this is an expected limitation?</p>



<a name="247652306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247652306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247652306">(Jul 29 2021 at 23:04)</a>:</h4>
<p>oh fun i've not seen this ICE before</p>



<a name="247652345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247652345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247652345">(Jul 29 2021 at 23:04)</a>:</h4>
<p>:)</p>



<a name="247653097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247653097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247653097">(Jul 29 2021 at 23:12)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=468fc7b8bad3e6ca1ebc3348c4759388">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=468fc7b8bad3e6ca1ebc3348c4759388</a></p>



<a name="247653100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247653100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247653100">(Jul 29 2021 at 23:12)</a>:</h4>
<p>more minimal</p>



<a name="247653157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247653157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247653157">(Jul 29 2021 at 23:13)</a>:</h4>
<p>as far as I can tell, it just doesn't like slices</p>



<a name="247654183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247654183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247654183">(Jul 29 2021 at 23:25)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_generics, const_evaluatable_checked)]</span><span class="w"></span>
<span class="cp">#![allow(incomplete_features)]</span><span class="w"></span>

<span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">S</span>: <span class="kp">&amp;</span><span class="o">'</span><span class="nb">static</span> <span class="p">[</span><span class="kt">usize</span><span class="p">]</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">S</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="p">{</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="247654186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247654186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247654186">(Jul 29 2021 at 23:25)</a>:</h4>
<p>even smaller repro lol</p>



<a name="247654768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247654768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247654768">(Jul 29 2021 at 23:33)</a>:</h4>
<p>as far as I can tell, that's because valtrees aren't implemented yet, so all const generics have to be primitive values</p>



<a name="247655300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247655300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247655300">(Jul 29 2021 at 23:41)</a>:</h4>
<p>Ah yeah, it might be because it's not a primitive or struct of primitives</p>



<a name="247655402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247655402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247655402">(Jul 29 2021 at 23:42)</a>:</h4>
<p>Well, in case anyone has any clever ideas, what I'm basically trying to do is make a shuffle function that can take any arbitrary length of indices and produce a vector of that length.  e.g take 8 elements from a vector of 4</p>



<a name="247655426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247655426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247655426">(Jul 29 2021 at 23:42)</a>:</h4>
<p>There aren't too many options in terms of API since the indices need to be const</p>



<a name="247655801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247655801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247655801">(Jul 29 2021 at 23:48)</a>:</h4>
<p>hmm.</p>



<a name="247656009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247656009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247656009">(Jul 29 2021 at 23:51)</a>:</h4>
<p>How about:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">ConstIndices</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">INDICES</span>: <span class="kp">&amp;</span><span class="o">'</span><span class="nb">static</span> <span class="p">[</span><span class="kt">usize</span><span class="p">];</span><span class="w"></span>
<span class="p">};</span><span class="w"></span>
<span class="fm">macro_rules!</span><span class="w"> </span><span class="n">const_indices</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="cp">$($index</span>:<span class="nc">expr</span><span class="p">),</span><span class="o">*</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">struct</span> <span class="nc">T</span><span class="p">;</span><span class="w"></span>
<span class="w">            </span><span class="k">impl</span><span class="w"> </span><span class="n">ConstIndices</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="k">const</span><span class="w"> </span><span class="n">INDICES</span>: <span class="kp">&amp;</span><span class="o">'</span><span class="nb">static</span> <span class="p">[</span><span class="kt">usize</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="cp">$($index</span><span class="p">),</span><span class="o">*</span><span class="p">];</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
<span class="w">            </span><span class="n">T</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">f</span><span class="o">&lt;</span><span class="n">I</span>: <span class="nc">ConstIndices</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span>: <span class="nc">I</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="fm">todo!</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="n">f</span><span class="p">(</span><span class="n">const_indices</span><span class="o">!</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">]);</span><span class="w"></span>
</code></pre></div>



<a name="247656589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247656589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247656589">(Jul 30 2021 at 00:00)</a>:</h4>
<p>Yeah, I came to the same conclusion that it needs to be an associated const, probably</p>



<a name="247656666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247656666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247656666">(Jul 30 2021 at 00:01)</a>:</h4>
<p>I don't like that you need to define a whole new type for each shuffle</p>



<a name="247656821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247656821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247656821">(Jul 30 2021 at 00:03)</a>:</h4>
<p>Though, then you could do something like</p>
<div class="codehilite"><pre><span></span><code>struct Shuffle4&lt;const INDICES: [usize; 4]&gt;;
struct Shuffle8&lt;const INDICES: [usize; 8]&gt;;
</code></pre></div>



<a name="247656938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/ICE/near/247656938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/ICE.html#247656938">(Jul 30 2021 at 00:05)</a>:</h4>
<p>You just wouldn't be able to make that generic over lane count (though that's starting to look like a HKT I think?)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>